<hook-action name="displayProfileTorrentHtml" args='pargs'>
    <style>
        .covered {
            color: rgb(51,51,51);
            background: rgb(51,51,51);
        }

        #posted li, #histories dd {
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }
    </style>
    <div class="space_profile">
        <h3><strong>Tracker信息</strong></h3>
        <!--# if ($pargs->visitUid == $pargs->spaceUid) { #-->
        <dl class="cc">
            <dt>个人密钥：</dt>
            <dd><span class="covered">{$pargs->passkey}</span></dd>
        </dl>

        <dl class="cc">
            <dt>订阅地址：</dt>
            <dd>
                <a href="{@WindUrlHelper::createUrl('/app/torrent/index/rss?passkey=' . $pargs->passkey)}">RSS（请勿泄露）</a>&nbsp;<a href="{@WindUrlHelper::createUrl('/like/mylike/run')}" class="btn">管理订阅</a>
            </dd>
        </dl>
        <!--# } #-->

        <dl class="cc">
            <dt>正在下载：</dt>
            <dd>{$pargs->leeching}</dd>
        </dl>
        <dl class="cc">
            <dt>正在做种：</dt>
            <dd>{$pargs->seeding}</dd>
        </dl>
        <dl class="cc">
            <dt>下载量：</dt>
            <dd>{@PwUtils::readableDataTransfer($pargs->downloaded_total)}</dd>
        </dl>
        <dl class="cc">
            <dt>上传量：</dt>
            <dd>{@PwUtils::readableDataTransfer($pargs->uploaded_total)}</dd>
        </dl>
        <dl class="cc">
            <dt>分享率：</dt>
            <dd>{@($pargs->downloaded_total != 0)?round($pargs->uploaded_total / $pargs->downloaded_total, 2):'Inf.'}</dd>
        </dl>
        <dl class="cc">
            <dt>下载时长：</dt>
            <dd>{@PwUtils::readableTime($pargs->leeched_total)}</dd>
        </dl>
        <dl class="cc">
            <dt>上传时长：</dt>
            <dd>{@PwUtils::readableTime($pargs->seeded_total)}</dd>
        </dl>
        <dl class="cc">
            <dt>分享占比：</dt>
            <dd>{@($pargs->leeched_total != 0)?round($pargs->seeded_total / $pargs->leeched_total * 100).' %':'Inf.'}</dd>
        </dl>
        <dl class="cc">
            <dt>发布种子：</dt>
            <dd>{@count($pargs->torrents)}&nbsp;<button class="btn" id="btnTogglePosted">显示/隐藏</button></dd>
        </dl>
        <div id="posted">
            <!--# if (is_array($pargs->torrents)) { #-->
            <!--# foreach($pargs->torrents as $torrent) { #-->
            <ul>
                <li><a href="{@WindUrlHelper::createUrl('/bbs/read/run?tid=' . $torrent['tid'])}">{$torrent['subject']}</a></li>
            </ul>
            <!--# } #-->
            <!--# } #-->
        </div>
        <dl class="cc">
            <dt>历史记录：</dt>
            <dd>{@count($pargs->histories)}&nbsp;<button class="btn" id="btnToggleHistories">显示/隐藏</button></dd>
        </dl>
        <div id="histories">
            <!--# if (is_array($pargs->histories)) { #-->
            <!--# foreach($pargs->histories as $torrent) { #-->
            <dl class="cc">
                <dd><a href="{@WindUrlHelper::createUrl('/bbs/read/run?tid=' . $torrent['tid'])}">{$torrent['subject']}</a></dd>
                <dt>
                    <!--# if ($torrent['left'] > 0) { #-->
                        未完成
                    <!--# } else { #-->
                        已完成
                    <!--# } #-->
                </dt>
            </dl>
            <!--# } #-->
            <!--# } #-->
        </div>
    </div>

    <script>
    Wind.ready(function() {
        $('#posted, #histories').hide();

        $('#btnTogglePosted').click(function() {
            $('#posted').slideToggle();
        });

        $('#btnToggleHistories').click(function() {
            $('#histories').slideToggle();
        });
    });
    </script>
</hook>
